package 力扣._00周赛._336周赛._100085_最小处理时间;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

public class Solution {
    public int minProcessingTime(List<Integer> processorTime, List<Integer> tasks) {
        int size = processorTime.size();
        for (int i = 0; i < size; i++) {
            processorTime.add(processorTime.get(i));
            processorTime.add(processorTime.get(i));
            processorTime.add(processorTime.get(i));
        }
        processorTime.sort(Comparator.comparingInt(o -> o));
        tasks.sort(((o1, o2) -> o2 - o1));

        int max = 0;
        for (int j = 0; j < tasks.size(); j++) {
            max  =Math.max(tasks.get(j)+processorTime.get(j),max);
        }
        return max;
    }

    public static void main(String[] args) {
        List<Integer> processorTime = new ArrayList<>();
        List<Integer> tasks = new ArrayList<>();
        processorTime.add(10);
        processorTime.add(20);
        tasks.add(2);
        tasks.add(3);
        tasks.add(1);
        tasks.add(2);
        tasks.add(5);
        tasks.add(8);
        tasks.add(4);
        tasks.add(3);
        int i = new Solution().minProcessingTime(processorTime, tasks);
        System.out.println(i);
    }
}
